package com.quan.common.core.support;

import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageInfo;
import com.quan.common.base.bean.PageBean;

import tk.mybatis.mapper.entity.Condition;

public interface IBaseService<T> {

	public T insert(T entity);

	public T insertSelective(T entity);

	public int update(T entity);

	public int update(T entity, Condition condition);

	public int updateSelective(T entity);

	public int updateSelective(T entity, Condition condition);

	public int delete(T entity);

	public int delete(Condition condition);

	public int deleteById(Object id);

	public int deleteByIds(String ids);

	public T selectOne(T entity);

	public T selectOneById(Object id);
	
	public List<T> selectAll();

	public List<T> selectAll(T entity);

	public List<T> selectAllByCondition(Condition condition);

	public int selectCount(T entity);

	public int selectCountByCondition(Condition condition);
	
	/**
	 * 检查该字段值是否存在
	 * @param entity 实体对象
	 * @param property 属性
	 * @param value 值
	 * @return 整形（0：不存在，>0：存在）
	 */
	public int existValue(Class<?> clazz, String property, Object value);
	
	/**
	 * 分页查询<br>
	 * <b style="color:red">注：需要自己定义相应的Mapper标签</b>
	 * @param entity 条件：实体对象
	 * @param pageBean 分页对象
	 * @return
	 */
	public PageInfo<T> selectPage(T entity, PageBean pageBean);

	/**
	 * 分页查询<br>
	 * <b style="color:red">注：需要自己定义相应的Mapper标签</b>
	 * @param params 条件：Map集合<对象属性, 值>
	 * @param pageBean 分页对象
	 * @return
	 */
	public PageInfo<T> selectPageByMap(Map<String, Object> params, PageBean pageBean);
	
	/**
	 * 分页查询
	 * @param condition 查询条件
	 * @param pageBean 分页对象
	 * @return
	 */
	public PageInfo<T> selectPageByCondition(Condition condition, PageBean pageBean);

}
